﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace Medianamik.UI.Controls
{
    [System.Web.UI.ToolboxData("<{0}:ConfirmedImageButton runat=\"server\"> </{0}:ConfirmedImageButton>")]
    public class ConfirmedImageButton : BetterImageButton
    {
        public virtual string ConfirmText
        {
            get
            {
                if (ViewState["ConfirmText"] == null)
                    return default(String);

                return ViewState["ConfirmText"].ToString();
            }
            set
            {
                ViewState["ConfirmText"] = value;
            }
        }

        public override void RenderBeginTag(System.Web.UI.HtmlTextWriter writer)
        {
            if (!String.IsNullOrEmpty(ConfirmText))
                writer.AddAttribute("onclick", String.Format("return confirm('{0}');",
                    ConfirmText));

            base.RenderBeginTag(writer);
        }
    }
}
